/*
 * @Author: xiaoyan
 * @Date: 2022-01-20 14:52:16
 * @LastEditors: xiaoyan
 * @LastEditTime: 2022-01-20 15:06:40
 * @Description: 共享数据中心
 * @FilePath: \user_auth_front\src\store\modules\share.ts
 */
const SET_USERLIST = "set_userList";
const SET_ROLELIST = "set_roleList";

interface MySate{
    userList:Array<any>,
    roleList:Array<any>,
}
const defaultState:MySate = {
    userList:[],
    roleList:[],
}
type TSetUserList = {
    type:String,
    payload:Array<any>,
}
type TSetRoleList = {
    type:String,
    payload:Array<any>,
}

export type Actions = TSetUserList | TSetRoleList;

export default (state:MySate = defaultState,action:Actions)=>{
    switch(action.type){
        case SET_USERLIST:
            return Object.assign({},state,{
                userList:action.payload
            });
        case SET_ROLELIST:
            return Object.assign({},state,{
                roleList:action.payload
            })
        default:
            return state;
    }
}
export const setUserList = (val:Array<any>)=>({
    type:SET_USERLIST,
    payload:val,
});
export const setRoleList = (val:Array<any>)=>({
    type:SET_ROLELIST,
    payload:val,
});